package cn.com.spic.demo.impl;

import cn.com.spic.demo.api.ActionProjectNoteService;
import cn.com.spic.demo.dao.ActionProDAO;
import cn.com.spic.demo.dao.ActionProNoteDAO;
import cn.com.spic.demo.dto.ActionProjectNoteDTO;
import cn.com.spic.demo.po.ActionProjectNotePO;
import cn.com.spic.demo.po.ActionProjectPO;
import cn.com.spic.demo.service.ActionNoteService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActionProjectNoteServiceImpl implements ActionProjectNoteService {
    @Autowired
    private ActionNoteService actionProNoteService;
    @Autowired
    private ActionProNoteDAO actionProNoteDAO;
    @Autowired
    private ActionProDAO actionProDAO;

    @Override
    public void saveActionProjectNote(ActionProjectNoteDTO actionProjectNoteDTO) {
        ActionProjectNotePO actionProjectNotePO = new ActionProjectNotePO();
        List<ActionProjectPO> pos = actionProDAO.getActionProDtos(actionProjectNoteDTO.getId());
        if (actionProjectNoteDTO != null) {
            BeanUtils.copyProperties(pos.get(0), actionProjectNotePO);
        }
        actionProjectNotePO.setCreatorId(actionProjectNoteDTO.getCreatorId());
        actionProjectNotePO.setEndTime(actionProjectNoteDTO.getEndTime());
        actionProjectNotePO.setAchievementResult(actionProjectNoteDTO.getAchievementResult());
        actionProNoteDAO.insertActionNoteVO(actionProjectNotePO);
    }
}
